package zx.acc.Util;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

public class DBConnection {
	public static final String USER;
	public static final String PASSWORD;
	public static final String URL;
	public static final String DRIVER;
	static{
		Properties pro = new Properties();
		try {
			pro.load(DBConnection.class.getResourceAsStream("Properties.properties"));
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			System.out.println("read is error "+e.getMessage());
		}
		USER = pro.getProperty("user");
		PASSWORD = pro.getProperty("password");
		URL = pro.getProperty("url");
		DRIVER = pro.getProperty("driver");
		try {
			Class.forName(DRIVER);
			
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			System.out.println("load is error "+e.getMessage());
		}
	}
	public static Connection getConnection() {
		Connection conn = null;
		try {
			conn = DriverManager.getConnection(URL, USER, PASSWORD);
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			System.out.println("connect is error "+e.getMessage());
		}
		return conn;
	}
	
}
